package com.mingqijia.gassafety.webserver.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.mingqijia.gassafety.db.entity.Dictionary;
import com.mingqijia.gassafety.db.entity.Dtu;
import com.mingqijia.gassafety.db.entity.FieldTemplate;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import com.mingqijia.gassafety.webserver.request.*;
import com.mingqijia.gassafety.webserver.request.client.ClientDtuListRequest;
import com.mingqijia.gassafety.webserver.request.inner.*;
import com.mingqijia.gassafety.webserver.response.ConsumerDtuHistoryResponse;
import com.mingqijia.gassafety.webserver.response.DtuInfoResponse;
import com.mingqijia.gassafety.webserver.response.DtuListResponse;
import com.mingqijia.gassafety.webserver.response.client.DtuResponse;
import com.mingqijia.gassafety.webserver.response.*;
import com.mingqijia.gassafety.webserver.response.inner.IotskDtuResponse;
import com.mingqijia.gassafety.webserver.response.workorder.asst.LoopInfoResponse;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 控制器表 服务类
 * </p>
 *
 * @author wanghai
 * @since 2022-02-21
 */
public interface EquipmentService extends IService<Dtu> {
    void saveDevice(SaveDeviceRequest request);

    Integer saveZJWifiDevice(ZJCreateBindRequest request);

    Integer saveUpdateZJWifiDevice(ZJCreateBindRequest request);


    Integer saveZJWifiDevice(ZJDeviceRegisterRequest request);

    void editEquipment(EditDeviceRequest request);

    DtuInfoResponse equipmentInfo(String equipmentId);

    void removeZJWifiDevice(String imei, String spId);

    void equipmentDelete(List<String> ids);

    void equipmentDelete(String id, String spId);

    PageUtil<DtuListResponse> equipmentList(EquipmentListRequest request);

    String importData(MultipartFile file);

    List<Dtu> getWithType2(LatestLogListRequest request);

    List<Dtu> listEquipmentWithType2(LatestLogListRequest request);


    List<Map<String, String>> dictMap(String type, List<String> types, String spId);

    /**
     * 更改 设备安装位置
     *
     * @param request
     */
    void editPosition(EquipmentPositionRequest request);

    /**
     * 更改 设备名
     *
     * @param request
     */
    void editEquipmentName(EquipmentPositionRequest request);


    void dictMapOpt(@Valid Dictionary request);

    PageUtil<ConsumerDtuHistoryResponse> bindingHistory(ConsumerDtuHistoryRequest request);

    PageUtil<DtuListResponse> bindEquipmentList(EquipmentListRequest request);

    /**
     * C端 用户报警器列表
     *
     * @param request
     * @return
     */
    List<DtuResponse> clientDtuListBySubs(ClientDtuListRequest request, String spId, FieldTemplate template);

    /**
     * 智慧厨房设备列表
     *
     * @param request
     * @return
     */
    List<IotskDtuResponse> clientDtuListIotSk(InnerDtuListRequest request);

    /**
     * for kitchen
     */
//    Map<String, List<DtuResponse>> clientDtuListBySubsArray(List<ClientDtuListRequest> requests, String spId, FieldTemplate template);

    /**
     * 获取所有客户的运行状态
     *
     * @return
     */
    List<ConsumerStatusResponse> consumerStatus();

    /**
     * 对客户绑定设备进行筛选
     *
     * @param consumerId
     * @return
     */
    PageUtil<ConsumerEquipmentResponse> consumerEquipment(ComsumerEquipmentRequest consumerId);

    /**
     * 获得用户设备的绑定解绑记录
     *
     * @param request
     * @return
     */
    PageUtil<ConsumerBindingHistoryResponse> consumerBindingHistory(ConsumerBindingHistoryRequest request);

    /**
     * v2.0点位设备落库
     *
     * @param dtuMap 设备及其探头数据
     * @param imei 主设备编码
     * @param point 点位号
     * @return
     */
    Dtu deviceInfo(Map<String,Dtu> dtuMap,String imei, String point);

    /**
     * 根据imei获得 dtu.id及相关信息
     *
     * @param imei
     * @param spId
     * @return
     */
    Dtu getDeviceByImei(String imei, String spId);

    /**
     * 根据imei批量获得 dtu.id及相关信息
     *
     * @param imei
     * @param spId
     * @return
     */
    List<Dtu> queryDeviceByImei(List<String> imeiList, String spId);

    /**
     * 根据imei和spId获得 dtu.id及相关信息
     *
     * @param imei
     * @param spId
     * @return
     */
    Dtu getDeviceByImeiAndSpIds(String imei, List<String> spId);

    /**
     * 根据 id获取设备的探测器和控制器
     *
     * @param deviceId
     * @return
     */
    List<Dtu> getAllDtuById(String deviceId);

    List<Dtu> queryEquipmentList(LatestLogListRequest request);

    List<Dtu> listEquipmentWithType1(LatestLogListRequest request);


    List<ConsumerEquipmentResponse> consumerEquipmentAsst(ComsumerEquipmentRequest request);

    void editInstallationAddress(EquipmentAddressRequest request);

    LoopInfoResponse loops(String iMEI);

    LoopInfoResponse equipmentInfo(String iMEI, int source);

    Map<String, Integer> loopAmount(@Valid LoopAmountRequest request);

    Map<String, Object> checkEquipment(String imei);

    List<String> equipmentModels(String manufacturer);

    List<Map<String, Object>> detectors(@Valid DetectorRequest request);

    void deviceSuitable( String imei);

    void editInstallDate(EquipmentPositionRequest request);

    /**
     * 智慧厨房设备列表
     *
     * @param request
     * @return
     */
    List<IotskDtuResponse> alarmEquipmentListFor(ZJAlarmEquipmentRequest request);

    /**
     * 获取设备厂商名称
     * @param equipmentManufacturerCode
     * @param spId
     * @return
     */
    String getEquipmentManufacturerName(String equipmentManufacturerCode,String spId);

    /**
     * 设备表高德转百度
     */
    void syncDtu();

    String deviceImportData(MultipartFile file);
}

